Skip to main content

Example: Element Collections

Product: CODESYS Base Libraries

The CODESYS library Element Collections contains function blocks for lists, queues, stacks, and hash tables. The elements of Collections are instances of function blocks of type IElement. The Element Collections Examples sample project shows how to use individual function blocks.

Description

The sample project includes the following applications:

  • ElementExample

    Shows the creation of instances of type IElement. IElement is the basic interface for all elements of this collection.

  • OnlineChangeSafeLinkedListExample

    Shows linked lists which are protected from online change.

  • SimpleHashTableExample

    Shows how to use the HashTable function block.

  • SimpleLinkedListExample

    Shows how to use the LinkedList function block. The LinkedList function block does not have index access and can be extended dynamically.

  • SimpleListExample

    Shows how to use the List function block. The List function block has methods with index access to the following elements: GetElementAt, InsertElementAt, RemoveElementAt, and SetElementAt.

  • SimpleQueueExample

    Shows how to use Queue function block. The Queue function block works according to the FIFO principle (first in, first out).

  • SimpleSortedListExample

    Shows how to use the SortedList function block. The elements of a SortedList are sorted by the ElementCompareTo method of IElement.

  • SimpleStackExample

    Shows how to use the Stack function block. The Stack function block works according to the LIFO principle (last in, first out).

  • SimpleTreeNodeExample

    Shows how to use the TreeNode function block. You can use the TreeNode function block to build tree structures.

  • DynamicListExample

    Shows how to use the ListFactory function block. You can use the ListFactory function block to create lists at runtime. These lists can be parameterized with a fixed size and also with an initial size with growth factor. The example demonstrates the general handling of a collection factory. The QueueFactory, SortedListFactory, StackFactory, and TreeNodeFactory work according to the same pattern.

System requirements and restrictions

Programming system

CODESYS Development System (version 3.5.14.0 or higher)

Runtime system

CODESYS Control Win (version 3.5.14.0)

Add-on components

-

Note

_example_icon.png DOWNLOAD Project